//
// SplitterChannel.h
//
// $Id: //poco/1.4/Foundation/include/Poco/SplitterChannel.h#1 $
//
// Library: Foundation
// Package: Logging
// Module:  SplitterChannel
//
// Definition of the SplitterChannel class.
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier:	BSL-1.0
//


#ifndef Foundation_SplitterChannel_INCLUDED
#define Foundation_SplitterChannel_INCLUDED


#include "Poco/Foundation.h"
#include "Poco/Channel.h"
#include "Poco/Mutex.h"
#include <map>


namespace Poco {

enum Channel_Type
{
	Channel_Type_Console,
	Channel_Type_File,
};

class Foundation_API SplitterChannel: public Channel
	/// This channel sends a message to multiple
	/// channels simultaneously.
{
public:
	SplitterChannel();
		/// Creates the SplitterChannel.

	void addChannel(Channel_Type type,Channel* pChannel);
		/// Attaches a channel, which may not be null.
		
	void removeChannel(Channel_Type type);
		/// Removes a channel.
	
	Channel* getChannel(Channel_Type type);

	virtual void log(const string& msg);
	
    virtual void log(const string& msg,LogPriority prio);
        
    virtual void log(const string& msg,LogPriority prio,const char* file,int line);

	void close();
		/// Removes all channels.
		
	int count() const;
		/// Returns the number of channels in the SplitterChannel.

	virtual ~SplitterChannel();

private:
	
	std::map<Channel_Type,Channel*>     m_channels;
	mutable FastMutex 					m_mutex;
};


} // namespace Poco


#endif // Foundation_SplitterChannel_INCLUDED
